<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 500px;
            height: 500px;
            border: 2px solid red;
            background: url(./0.jpg);
            /* 使用background-size来控制背景图片大小 */
            /* background-size: 100%; */

            /* cover要求完全覆盖父标签 */
            /* background-size: cover; */

            /* contain 可以等比例拉伸，直至图片任何一边触碰父标签即停 */
            background-size: contain;
            
            background-repeat: no-repeat;
        }
    </style>
</head>

<body>
    <div></div>
</body>

</html>